package day_2022_4_to_7.day48;

public class toString {
    public static void main(String[] args) {
        int[] arr=new int[]{1,2,3,4,5};
        System.out.println(toString(arr));
        System.out.println(toString1(arr));
    }

    public static String toString(int[] arr){
        String str="[";
        for (int i = 0; i < arr.length; i++) {
            str+=arr[i];
            if(i!=arr.length-1){
                str+=",";
            }
        }
        str+="]";
        return str;
    }

    public static String toString1(int[] arr){
        StringBuilder str=new StringBuilder();
        str.append("[");
        for (int i = 0; i < arr.length; i++) {
            str.append(arr[i]);
            if(i!=arr.length-1){
                str.append(",");
            }
        }
        str.append("]");
        return str.toString();
    }
}


